package lhdx12;

public class Teacher {
    private String xingM;
    private String xueX;
    private int nianL;

    public String getXingM() {
        return xingM;
    }

    public void setXingM(String xingM) {
        this.xingM = xingM;
    }

    public String getXueX() {
        return xueX;
    }

    public void setXueX(String xueX) {
        this.xueX = xueX;
    }

    public int getNianL() {
        return nianL;
    }

    public void setNianL(int nianL)throws Exception {
        if (nianL>22){
            this.nianL = nianL;
        }else {
            throw new Exception("年龄要大于22岁");
        }

    }

    public Teacher(String xingM, String xueX) {
        this.xingM = xingM;
        this.xueX = xueX;
    }
    public void shangKe(){
        System.out.println(xingM+"老师正在上课。。。。");
    }
    public void jieS(){
        System.out.println(xingM+"老师在"+xueX+"学校任教。"+"今年"+nianL+"岁。");
    }
}
